
//����������
package com.creawor.hz_market.t_information;
import java.util.Date;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;

import com.creawor.hz_market.util.ComQuery;
import com.creawor.imei.base.AbsEditMap;

public class t_information_EditMap extends AbsEditMap {

public void add(t_information_Form vo) throws HibernateException {
t_information po=new t_information();
  try{
    //po.setId(java.lang.Integer.parseInt(vo.getId()));
  }catch (Exception e) {
//   e.printStackTrace();
  }

  try{
   po.setName(vo.getName());
   po.setLeveltype(vo.getLeveltype());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setContent(vo.getContent());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setWriter(vo.getWriter());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setUpdated_day(new Date());
  }catch (Exception e) {
   e.printStackTrace();
  }
  
  try{
	   po.setReview_date(com.creawor.km.util.DateUtil.getDate(vo.getReview_date(),"yyyy-MM-dd"));
	//   po.setUpdated_day(new Date());
	  }catch (Exception e) {
	   e.printStackTrace();
	  }
  try{
	   po.setReview_flag(0);
	  }catch (Exception e) {
	   e.printStackTrace();
	  }
  try{
   po.setCounty(vo.getCounty());
   po.setType(vo.getType());
   po.setCompany(vo.getCompany());
   po.setReview_user(vo.getReview_user());
   po.setAlert_level(vo.getAlert_level());
   po.setInfo_level(vo.getInfo_level());
   po.setInfo_type(vo.getInfo_type());
  }catch (Exception e) {
   e.printStackTrace();
  }
  po.setOpentype(vo.getOpentype());
  po.setUpdated_day(new Date());
		Session session = this.beginTransaction();
try {
	session.save(po);
	vo.setId(String.valueOf(po.getId()));
	this.endTransaction(true);
} catch (Exception e) {
	this.endTransaction(false);
	e.printStackTrace();
   throw new HibernateException(e);}	
}

public void delete(t_information_Form vo) throws HibernateException {
String id = vo.getId();
delete(id);
}

public void delete(String id) throws HibernateException {
Session session = this.beginTransaction();
try{
 t_information po =(t_information) session.load(t_information.class, new Integer(id));
 session.delete(po);
 this.endTransaction(true);
} catch (HibernateException e) {
  e.printStackTrace();
  this.endTransaction(false);
}
}

public void update(t_information_Form vo) throws HibernateException {
	Session session = this.beginTransaction();
   String id = vo.getId();
   t_information po =(t_information) session.load(t_information.class, new Integer(id));
  try{
    po.setId(java.lang.Integer.parseInt(vo.getId()));
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setName(vo.getName());
   po.setLeveltype(vo.getLeveltype());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setContent(vo.getContent());
   po.setReview_user(vo.getReview_user());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setWriter(vo.getWriter());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setUpdated_day(new Date());
  }catch (Exception e) {
   e.printStackTrace();
  }

  try{
   po.setCounty(vo.getCounty());
   po.setAlert_level(vo.getAlert_level());
   po.setInfo_level(vo.getInfo_level());
   po.setInfo_type(vo.getInfo_type());
  }catch (Exception e) {
   e.printStackTrace();
  }
  try{
	   po.setReview_date(com.creawor.km.util.DateUtil.getDate(vo.getReview_date(),"yyyy-MM-dd"));
	//   po.setUpdated_day(new Date());
	  }catch (Exception e) {
	   e.printStackTrace();
	  }

  try{
	   po.setReview_flag(Integer.parseInt(vo.getReview_flag()));
	  }catch (Exception e) {
	   e.printStackTrace();
	  }
  po.setUpdated_day(new Date());
  po.setOpentype(vo.getOpentype());
try {
	session.update(po);

	this.endTransaction(true);
} catch (Exception e) {
	this.endTransaction(false);
	e.printStackTrace();
   throw new HibernateException(e);  }
}

public void setReviewFlag(String infoId){
	String sql="update t_information set review_flag=5 where id="+infoId;
	
	ComQuery stm=new ComQuery();
	stm.updateDB(sql);
}

public static void main(String[]args){
	try {
			t_information_EditMap edit=new t_information_EditMap();
			t_information_Form po=new t_information_Form();
			po.setAlert_level("11111111");
			po.setName("1111111111111");
			po.setCompany("111111111");
			Transaction tx=	edit.transaction;
			edit.add(po);
			tx.commit();
	} catch (HibernateException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	
	
}
}
//����������
